package com.hww.slow_sql;

import lombok.Data;
import org.apache.ibatis.plugin.Invocation;

import java.io.Serializable;

/**
 * 慢SQL实体对象
 * @author xiaojie
 * @date 2021/1/9 1:58 上午
 */
@Data
public class SlowSQLDTO implements Serializable {

    private static final long serialVersionUID = 5554908844009922571L;

    /** SQL执行的初始时间 */
    private long start;

    /** SQL执行的结束时间或者异常时间 */
    private long end;

    /** 执行对象 */
    private Invocation invocation;

    /** 异常 */
    private Throwable exception;

    /** 查询的行数 */
    private int queryRowCount;

    /** 追溯ID */
    private String traceId;

    public SlowSQLDTO(long start, long end, Invocation invocation, Throwable exception) {
        this.start = start;
        this.end = end;
        this.invocation = invocation;
        this.exception = exception;
    }
    public SlowSQLDTO(long start, long end, Invocation invocation, Throwable exception, int queryRowCount) {
        this.start = start;
        this.end = end;
        this.invocation = invocation;
        this.exception = exception;
        this.queryRowCount = queryRowCount;
    }


    public SlowSQLDTO(long start, long end, Invocation invocation, Throwable exception, int queryRowCount, String traceId) {
        this.start = start;
        this.end = end;
        this.invocation = invocation;
        this.exception = exception;
        this.queryRowCount = queryRowCount;
        this.traceId = traceId;
    }

}
